import unittest
import app

from api.loginAPI import loginAPI
from utils import common_assert
class testLogin(unittest.TestCase):

    def setUp(self):
        self.loginAPI = loginAPI()


    def tearDown(self):
        pass



    def test01_case001(self):

        response = self.loginAPI.login({"mobile": "13800000002", "password": "123456"})
        print(response.json())

        common_assert(self, response)



        token = response.json().get("data")
        app.token = "Bearer " + token
        print(app.token)

        app.header["Authorization"] = app.token

        print(app.header)



    def test02_case002(self):

        response = self.loginAPI.login({"mobile": "", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")



    def test03_case003(self):

        response = self.loginAPI.login({"mobile": "13800000002", "password": ""})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")

    def test04_case004(self):

        response = self.loginAPI.login({"mobile": "1380000000", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")


    def test05_case005(self):

        response = self.loginAPI.login({"mobile": "138000000021", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")

    def test06_case006(self):

        response = self.loginAPI.login({"mobile": "qqqqqqqqqqq", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")



    def test07_case007(self):

        response = self.loginAPI.login({"mobile": "13800000009", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")

    def test08_case008(self):

        response = self.loginAPI.login({"mobile": "13800000002", "password": "123456", "params": "hahha"})
        print(response.json())

        common_assert(self, response)

    def test09_case009(self):

        response = self.loginAPI.login({"password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")


    def test10_case010(self):

        response = self.loginAPI.login({"mobile": "13800000002"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")

    def test11_case011(self):

        response = self.loginAPI.login(None)
        print(response.json())

        common_assert(self, response, success=False, code=99999, message="抱歉，系统繁忙，请稍后重试")

    def test12_case0012(self):

        response = self.loginAPI.login({"mobiel": "13800000002", "password": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")


    def test13_case0013(self):

        response = self.loginAPI.login({"mobile": "13800000002", "password1": "123456"})
        print(response.json())

        common_assert(self, response, success=False, code=20001, message="用户名或密码错误")